import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PayGroupVO, PayGroupForm, PayGroupQuery } from './types';

/**
 * 查询轮询组列表
 * @param query
 * @returns {*}
 */

export const listPayGroup = (query?: PayGroupQuery): AxiosPromise<PayGroupVO[]> => {
  return request({
    url: '/system/PayGroup/list',
    method: 'get',
    params: query
  });
};

export const PayChartGroup = (groupIds: Array<number | string>) => {
  return request({
    url: '/system/PayChart/group',
    method: 'post',
    data: {
      groupIds
    }
  });
};

/**
 * 查询轮询组详细
 * @param groupId
 */
export const getPayGroup = (groupId: string | number): AxiosPromise<PayGroupVO> => {
  return request({
    url: '/system/PayGroup/' + groupId,
    method: 'get'
  });
};

/**
 * 新增轮询组
 * @param data
 */
export const addPayGroup = (data: PayGroupForm) => {
  return request({
    url: '/system/PayGroup',
    method: 'post',
    data: data
  });
};

/**
 * 修改轮询组
 * @param data
 */
export const updatePayGroup = (data: PayGroupForm) => {
  return request({
    url: '/system/PayGroup',
    method: 'put',
    data: data
  });
};

/**
 * 拷贝轮询组
 * @param data
 */
export const copyPayGroup = (data: PayGroupForm) => {
  return request({
    url: '/system/PayGroup/copy',
    method: 'post',
    data: data
  });
};

/**
 * 删除轮询组
 * @param groupId
 */
export const delPayGroup = (groupId: string | number | Array<string | number>) => {
  return request({
    url: '/system/PayGroup/' + groupId,
    method: 'delete'
  });
};
